#include <iostream>
using namespace std;

class student
{
private:
    int age;
    double degree;
    string name;
public:
    student(int ageValue, double degreeValue, string nameValue);
    void getDegree();
    void setAge();
    void getAge();
};    

int main()
{
    student xioaming(15, 84.5, "xiaoming"), xiaowang(17, 90.7, "xiaowang");
    xiaowang.getDegree();
    xioaming.getDegree();
    xiaowang.getAge();
    xiaowang.setAge();
    xiaowang.getAge();

    return 0;
}

student::student(int ageValue, double degreeValue, string nameValue)
    : age(ageValue), degree(degreeValue), name(nameValue)
{}

void student::getDegree()
{
    cout << "The degree of " << name << " is " << degree << endl;
}

void student::getAge()
{
    cout << "The age of " << name << " is " << age << endl;
}

void student::setAge()
{
    int newAge;
    cout << "Enter in the new age of " << name << ": ";
    cin >> newAge;
    while (newAge > 30)
    {
        cout << "Too old !" << endl
             << "Try again: " << endl;
        cin >> newAge;
    }
    age = newAge;
}